<%@ include file="/common/taglibs.jsp"%>
<title><fmt:message key="registrationList.title"/></title>
<content tag="heading"><fmt:message key="registrationList.heading"/></content>
<meta name="menu" content="RegistrationMenu"/>

<script type="text/javascript">
  function getHTML(params, divId, urlToGet)
  {
      var url = 'ajax_registrations.html';
	  if ( urlToGet != null ) {
	  	url = urlToGet;
      }

      var pars = 'search=&';
      pars = pars + Form.serialize("searchRegistrationForm");

	  if ( params != null ) {
	  	pars = params;
	  }
	  if ( divId == null ) {
	  	divId = 'registrationListDiv';
	  }
      var myAjax = new Ajax.Updater(
          divId,
          url,
          {
              method: 'get',
              parameters: pars,
              evalScripts: true
          }
      );

	  return false;
  }

  var myGlobalHandlers = {
    onCreate: function(){
      Element.hide('registrationListDiv');
      Element.show('systemWorking');
    },

    onComplete: function() {
      if(Ajax.activeRequestCount == 0){
        Element.show('registrationListDiv');
        Element.hide('systemWorking');
      }
    }
  };

  function saveRegistration()
  {
  	var params = 'modify=&' + Form.serialize('registrationForm');
  	getHTML(params, 'editRegistration');
  }

/*  Ajax.Responders.register(myGlobalHandlers); */
</script>

    <script type="text/javascript">
    function toggleAssignment(id,visible)
    {
      var assignmentDiv = id;

    if (visible)
    {
      Effect.SlideDown($(assignmentDiv));
    }
    else
    {
      // TODO: uncheck all assignment boxes...?
      Effect.SlideUp($(assignmentDiv));
    }
    }
  </script>
<div id="searchAdd">
	<div id="searchBox">
	<form:form commandName="registration" method="get" action="#" id="searchRegistrationForm" onsubmit="getHTML(); return false">
		<div class="box" style="width: 250px;" id="searchRegistration">
		<div id="formElements">
		        <icnmember:label styleClass="desc" key="registration.ticketNumbers"/>
		        <form:errors path="ticketNumbers" cssClass="fieldError"/>
		        <form:input path="ticketNumbers" id="ticketNumbers" cssClass="text medium"/>

		        <icnmember:label styleClass="desc" key="registration.firstName"/>
		        <form:errors path="firstName" cssClass="fieldError"/>
		        <form:input path="firstName" id="firstName" cssClass="text medium"/>

		        <icnmember:label styleClass="desc" key="registration.lastName"/>
		        <form:errors path="lastName" cssClass="fieldError"/>
		        <form:input path="lastName" id="lastName" cssClass="text medium"/>

		        <icnmember:label styleClass="desc" key="registration.phone"/>
		        <form:errors path="phone" cssClass="fieldError"/>
		        <form:input path="phone" id="phone" cssClass="text medium"/>

		        <icnmember:label styleClass="desc" key="registration.email"/>
		        <form:errors path="email" cssClass="fieldError"/>
		        <form:input path="email" id="email" cssClass="text medium"/>

				<div class="clear">
		        <icnmember:label key="registration.onlinePurchase"/>
		        <form:errors path="onlinePurchase" cssClass="fieldError"/>
		        <form:checkbox path="onlinePurchase" id="onlinePurchase"/>
		        </div>
		</div>
		<div id="buttons" class="buttonBar">
		        <input type="submit" value="Search"/>
				<input type="submit" onclick="Form.reset('searchRegistrationForm'); return false;" value="Clear"/>
		</div>
		</div>
	</form:form>
	</div>

	<div id="addRegistration">
	<a href="#addRegistration"></a>
<!--		<a href="#" onclick="toggleAnimated('editRegistration');return false;">Add New Registration...</a>-->
		<div class="box" id="editRegistration" style="width: 450px">
		<c:import url="ajax_editRegistration.jsp"></c:import>
		</div>
	 </div>
 </div>
<div id='systemWorking' style="display:none;"><img src='images/spinner.gif'> Loading...</div>
<div id="registrationListDiv">
	<c:import url="ajax_registrationList.jsp"></c:import>
</div>